<template>
	<view class="">
		<view class="nav_top-bg">
			<u-navbar title="材料商详情">
				<view class="u-nav-slot" slot="left">
					<u-icon name="arrow-left" @click="go_black" size="19"></u-icon>
					<u-line direction="column" :hairline="false" length="16" margin="0 10px"></u-line>
					<u-icon name="home" @click="goHome" size="20"></u-icon>
				</view>
			</u-navbar>
		</view>
		<view class="top-bg"
			:style="'background: url(' + company_info.company_bg_image_url + ') center top no-repeat; background-size: 100% auto'">
			<image @click="shoucang_click" :src="company_info.shoucang == 1 ? '../static/shoucang_xz_icon.png' : '../static/shoucang_icon.png'" mode="widthFix" class="shoucang"></image>
			<view class="d-flex">
				<view class="shigong_company">
					<view class="w-650">
						<view class="d-flex align-items">
							<image class="touxiang-img" :src="company_info.user.avatar" mode=""></image>
							<view class="">
								<view class="name-t">{{company_info.company_name}}</view>
								<view class="d-flex align-items justify-content-space-between cls">
									<view class="type-list-m1">{{company_info.groupname}}</view>
									<view class="company-t d-flex align-items">
										<image class="dwImg" src="../../static/jianfang/dw.png" mode="widthFix"></image>
										{{company_info.company_cityname}} {{company_info.company_areaname}}
									</view>
								</view>
							</view>
						</view>
						<!-- <view class="zhuying">公司主营：{{company_info.company_zhuying}}</view> -->
					</view>
				</view>
			</view>
			<view class="shigongdui_xx">
				<view class="w-650">
					<view class="tit">
						<view class="line"></view>
						<view class="tit-size">公司介绍</view>
					</view>
					<view class="">
						<view class="sgd-xq">联 &nbsp;系&nbsp;人：<text
								class="sgd-xq-js">{{company_info.company_contact}}</text> </view>
						<view class="">
							<view class="sgd-xq">公司介绍：</view>
							<view class="sgd-xq-js">{{company_info.instr}}</view>
						</view>

					</view>
				</view>
			</view>
			<!-- 证件资质 -->
			<view class="shigongdui_xx">
				<view class="w-650">
					<view class="tit">
						<view class="line"></view>
						<view class="tit-size">证件资质</view>
					</view>
					<image class="zizhi" v-for="(img,index) in company_info.company_zhizhao_url" :src="img"
						mode="widthFix"></image>
				</view>
			</view>
			<!-- 商品详情 -->
			<view class="" style="padding-bottom: 120rpx;">
				<view class="fabu-info">
					<view class="shops">
						<view class="tit">
							<view class="line"></view>
							<view class="tit-size">材料信息</view>
						</view>
						<!-- 商品列表 -->
						<view class="shopping d-flex align-items justify-content-space-between">
							<view class="shopping_list" @click="go_shop(item)" v-for="(item,index) in items" :key="index">
								<image class="shopping_phone" :src="item.zhutu_images_firsturl"
									mode="widthFix"></image>
								<view class="">
									<view class="sp-name">{{item.content2.title}}</view>
									<view class="sp-num"> <text class="fuhao">￥</text> {{item.price}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部按钮 -->
		<view class="foot_btn d-flex align-items justify-content-center">
			<view class="foot_btn-but">
				<u-button text="获取联系方式" @click="get_phone" color="#FF6400"></u-button>
			</view>
		</view>
		<!-- 获取电话弹窗 -->
		<view class="">
			<u-popup :show="show_pop" round="10" :safeAreaInsetBottom="false" mode="center" @close="close">
				<view class="get_phone">
					<view class="phone-t">联系方式</view>
					<view class="phone-num">{{company_info.company_phone}}</view>
					<!-- <view class="shengyu">剩余免费次数：<text class="cishu">2次</text> </view> -->
					<view class="phone-w">
						<u-button text="确定" shape="circle" @click="queding" color="#FF6400"></u-button>
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	import {
		getGroupUserinfo,
		getXinxilist,
		setshouchangshop
	} from '@/api/user.js'
	export default {
		data() {
			return {
				type: '',
				navTitle: '',
				show_pop: false,
				user_id: '',
				company_info: {},
				items: {},
				page:1,
				limit:7,
				infotype_id: '',
			}
		},

		onLoad(option) {
			this.type = option.id
			this.user_id = option.user_id
			this.infotype_id = option.infotype_id
			console.log("接受的订单的", option);
			this.get_compeny_info()
			this.get_jianfang_list()
		},
		methods: {
			// 获取公司信息
			get_compeny_info() {
				var data = {
					group_id: this.type,
					user_id: this.user_id
				}
				getGroupUserinfo(data).then(res => {
					console.log("获取公司信息", res);
					if (res.code == 1) {
						this.company_info = res.data.user_groupinfo
					}
				})
			},
			// 获取我发布的信息列表
			get_jianfang_list() {
				console.log("88888888", this.anli_list);
				var data = {
					page: this.page,
					limit: this.limit,
					type:'10',
					user_id:this.user_id,
					group_id: this.type,
				}
				getXinxilist(data).then(res => {
					console.log("的发生大法师", res);
					if (res.code == 1) {
						if (this.page == 1) {
							this.items = res.data.list
						} else {
							this.items = this.items.concat(res.data.list)
						}
						uni.stopPullDownRefresh()
					}
				})
			},
			go_black() {
				uni.navigateBack({
					delta: 1
				})
			},
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			anli_click(item) {
				console.log('item', item);
				this.current = item.index
			},
			get_phone() {
				this.show_pop = true
			},
			go_shop(e){
				uni.navigateTo({
					url:'/pagesA/anli_zhanshi/shopping?id=' + e.content_id + '&infotype_id=' + e.infotype_id
				})
			},
			queding() {
				this.show_pop = false
			},
			// 点机收藏按钮
			shoucang_click() {
				console.log("点击收藏按钮");
				var data = {
					group_id: this.type,
					user_id: this.user_id
				}
				console.log("数据库为", data);
				setshouchangshop(data).then(res => {
					console.log("收藏的店铺为", res);
					if (res.code == 1) {
						uni.showToast({
							title: '收藏成功',
							icon: 'success'
						})
						this.get_compeny_info()
					} else {
						uni.showToast({
							title: '取消收藏',
							icon: 'none'
						})
						this.get_compeny_info()
					}
				})
			},
		}
	}
</script>

<style>
	/* 获取电话弹窗 */
	.get_phone {
		width: 540rpx;
	}

	.phone-t {
		font-size: 34rpx;
		font-weight: 600;
		text-align: center;
		color: #1D2129;
		margin-bottom: 53rpx;
		padding-top: 40rpx;
	}

	.phone-num {
		font-size: 56rpx;
		font-weight: 600;
		text-align: center;
		color: #232323;
		margin-bottom: 30rpx;
	}

	.shengyu {
		font-size: 28rpx;
		font-weight: normal;
		color: #999999;
		text-align: center;
	}

	.cishu {
		font-size: 28rpx;
		font-weight: normal;
		color: #232323 !important;
	}

	.phone-w {
		width: 480rpx;
		margin: auto;
		margin-top: 29rpx;
		padding-bottom: 30rpx;
	}

	/* end */
	.fuhao {
		font-size: 24rpx;
		font-weight: 600;
		color: #FF4D4F;
	}

	.sp-num {
		font-size: 36rpx;
		font-weight: 600;
		color: #FF4D4F;
		margin: 0rpx 0 15rpx 24rpx;
	}

	.sp-name {
		width: 295rpx;
		font-size: 30rpx;
		color: #333;
		font-weight: 600;
		margin-left: 20rpx;
		margin-top: 20rpx;
		overflow: hidden;
		display: -webkit-box;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.shopping_phone {
		width: 306rpx;
		display: block;
		border-top-right-radius: 8rpx;
		border-top-left-radius: 8rpx;
	}

	.shopping_list {
		width: 306rpx;
		background-color: #fff;
		border-radius: 8rpx;
	}

	.shopping {
		width: 640rpx;
		margin: auto;
		flex-wrap: wrap;
	}

	.tit-size {
		font-size: 36rpx;
		font-weight: 600;
		margin-left: 10rpx;
		color: #333;
	}

	.tit {
		display: flex;
		align-items: center;
		margin-top: 20rpx;
		margin-bottom: 30rpx;
	}

	.shops {
		width: 640rpx;
		margin: 30rpx auto;
		padding-top: 20rpx;
	}

	.fabu-info {
		width: 690rpx;
		background-color: #fff;
		margin: auto;
		border-radius: 10rpx;
	}

	.zizhi {
		width: 650rpx;
		display: block;
	}

	.cls {
		width: 520rpx;
	}

	.foot_btn-but {
		width: 670rpx;
		margin: auto;
	}

	.foot_btn {
		width: 750rpx;
		height: 128rpx;
		position: fixed;
		bottom: 0;
		background-color: #fff;
		box-shadow: 0rpx 4rpx 23rpx 0rpx #999;
	}

	.type-list-m1 {
		padding: 7rpx 15rpx;
		font-size: 20rpx;
		color: #FF4D4F;
		border-radius: 4.5px;
		background: #FDF2F2;
		margin-right: 10rpx;
	}

	.sgd-xq-js {
		font-size: 30rpx;
		color: #333;
	}

	.sgd-xq {
		font-size: 30rpx;
		color: #9E9E9E;
		line-height: 50rpx;
	}

	.line {
		width: 8rpx;
		height: 38rpx;
		background: #FF6400;
	}

	.shigongdui_xx {
		width: 690rpx;
		background-color: #fff;
		border-radius: 10rpx;
		margin: 20rpx auto;
		padding: 30rpx 0;
	}

	.zhuying {
		font-size: 24rpx;
		font-weight: normal;
		line-height: 42rpx;
		color: #4D5150;
		margin-top: 20rpx;
	}

	.touxiang-img {
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
		display: block;
		margin-right: 10rpx;
	}

	.name-t {
		font-size: 32rpx;
		font-weight: 600;
		color: #1C2023;
		margin-bottom: 10rpx;
	}

	.dwImg {
		width: 32rpx;
		display: block;
	}

	.company-t {
		font-size: 24rpx;
		color: #999999;
		margin-top: 10rpx;
		margin-left: 10rpx;
	}

	.shoucang {
		width: 64rpx;
		display: block;
		position: absolute;
		top: 30rpx;
		right: 40rpx;
	}

	.shigong_company {
		width: 690rpx;
		margin: auto;
		margin-top: 330rpx;
		background-color: #fff;
		border-radius: 10rpx;
		padding: 30rpx 0;
	}

	.top-bg {
		width: 750rpx;
		height: 434rpx;
		position: relative;
		background: url('https://lianfan.nccpu.cn/image/anli1.png') no-repeat;
		background-size: 100% auto;
	}

	page {
		background-color: #F7F8FB;
	}
</style>